//
//  ChartingTopView.m
//  intelligent
//
//  Created by 甘世清 on 2024/2/29.
//

#import "ChartingTopView.h"
#import "ZSViewController.h"
@implementation ChartingTopView

- (void)SQ_UIViewForSelfView{
    self.backgroundColor = UIColor.clearColor;
    [self addSubview:self.textField];
    [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(16);
        make.height.mas_equalTo(36);
        make.width.mas_equalTo(SCREEN_WIDETH-120);
        make.bottom.equalTo(self.mas_bottom).offset(-20);
    }];
    [self addSubview:self.right];
    [self.right mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(50);
            make.right.equalTo(self.mas_right);
            make.left.equalTo(self.textField.mas_right);
            make.centerY.equalTo(self.textField);
    }];
    WS(weakSelf);
    [self.right setTouchBlock:^(SQCustomButton * _Nonnull button) {
        ZSViewController * vc = [[ZSViewController alloc]init];
        [[Manager SQ_getCurrentViewController].navigationController pushViewController:vc animated:YES];
    }];
}
 
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [self.textField resignFirstResponder];
    return  YES;
}
- (void)setIntegral:(int)integral{
    _integral = integral;
    self.right.text = [NSString stringWithFormat:@"%d",integral];
}
 

- (UITextField *)textField{
    if (!_textField) {
        _textField = [[UITextField alloc]init];
        _textField.backgroundColor = UIColor.whiteColor;
        _textField.placeholder = SQNSLocalString(@"输入你想画的内容关键词，例如：猫");
        _textField.textColor = SQColor333333;
        _textField.layer.cornerRadius = 18;
        _textField.textAlignment = NSTextAlignmentCenter;
        _textField.font = FONT_REGULAR(14);
        _textField.delegate = self;
        _textField.returnKeyType = UIReturnKeyDone;
        _textField.layer.masksToBounds = YES;
        UIView * bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 30, 36)];
        UIImageView * lefe = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 16, 16)];
        lefe.image = SQGetImage(@"输入");
        lefe.contentMode = UIViewContentModeScaleAspectFit;
        [bgView addSubview:lefe];
        _textField.leftViewMode = UITextFieldViewModeAlways;
        _textField.leftView = bgView;
        [_textField setValue:SQColor999999 forKeyPath:@"placeholderLabel.textColor"];
    }
    return _textField;
}
- (SQCustomButton *)right{
    if (!_right) {
        _right = [[SQCustomButton alloc]initType:SQCustomButtonLeftImageType imageSize:CGSizeMake(20, 22) midmargin:6];
        _right.image = SQGetImage(@"金币");
        _right.text  = @"0";
        _right.font = FONT_MEDIUM(14);
        _right.textColor = SQColor333333;
    }
    return _right;
}
@end
